<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui" 
        xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Add Movie</title>
    </h:head>
    <h:body rendered="#{userService.currentUser.isLoggedIn}" >
        <div>
        <h:form id="form11">
            <p:commandButton value="Search" action="search.jsf" />
            <p:commandButton value="Add Movie" action="addmovie.jsf" />
            <p:commandButton value="Add Movie For All" action="#{userService.easyAccesstoAddMovie}" />
            <p:commandButton value="Upload" action="upload.jsf" />
            <p:commandButton value="Logout" actionListener="#{userService.logout()}" />
            <!--<p:commandButton value="List Movies" action="allmovies.jsf" />-->
        </h:form>
            <h:form id="form" rendered="#{userService.currentUser.subscriber == 1}">
                <p:panel id="panel" header="New Movie" style="margin-bottom:10px;">  
                    <p:messages id="messages" autoUpdate="true" />
                    <p:panelGrid id="pg" columns="2" >
                        <h:outputText value="Id: " />
                        <p:inputText value="#{movieService.editedMovie.id}" >
                            <p:ajax update="panelgridid" event="keyup" listener="#{movieService.updateEditedMovie(movieService.editedMovie.id)}" />
                        </p:inputText>
                        
                    </p:panelGrid>
                    <p:panelGrid id="panelgridid" columns="2" >
                        
                        <h:outputText value="Title: " />
                        <p:inputText value="#{movieService.editedMovie.title}" />
                        
                        <h:outputText value="Release year: " />
                        <p:inputText value="#{movieService.editedMovie.releaseYear}" />
                        
                        <h:outputText value="Genre: " />
                        <p:inputText value="#{movieService.editedMovie.genre}" />
                    </p:panelGrid>
                </p:panel>
                <p:commandButton value="Submit (secure)" update="panel" actionListener="#{movieService.editMovie(userService)}" />
                <p:commandButton value="Submit (insecure)" action="#{movieService.editMovieNotSafely(userService)}" />
            </h:form>
            <p:panel id="panel1" rendered="#{userService.currentUser.subscriber == 0}" >
                You are not a subscriber! You can't edit movies.
            </p:panel>
        </div>
    </h:body>
    <h:body rendered="#{userService.currentUser.isLoggedIn == false}">
        You're not allowed to be on this page, while not being logged in!
        <br/>
        <h:form>
            <p:commandLink id="redirectlink" action="index.jsf" >Log in</p:commandLink>
        </h:form>
    </h:body>
</html>
